package com.hl.wuyeguanliIDEA.web;

import com.hl.wuyeguanliIDEA.pojo.EventReminder;
import com.hl.wuyeguanliIDEA.pojo.SystemPassword;
import com.hl.wuyeguanliIDEA.service.SystemPasswordService;
import com.hl.wuyeguanliIDEA.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/systemPassword")
public class SystemPasswordController {

    @Autowired
    private SystemPasswordService systemPasswordService;
    @GetMapping("/selectAll")
    public ResponseEntity<List<SystemPassword>> selectAll() {
        List<SystemPassword> systemPasswords = systemPasswordService.selectAll();
        return new ResponseEntity<>(systemPasswords, HttpStatus.OK);
    }

    // 根据 ID 查询系统密码
    @GetMapping("/{id}")
    public ResponseResult<SystemPassword> getPasswordById(@PathVariable Integer id) {
        SystemPassword systemPassword = systemPasswordService.getPasswordById(id);
        if (systemPassword != null) {
            return ResponseResult.success(systemPassword);
        } else {
            return ResponseResult.error(404, "未找到对应的密码信息");
        }
    }

}